home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 751-760 / 756 / run68013 / run68013.s < prev    next >
Text File  |  1995-03-18  |  30KB  |  1,433 lines

  1. ;Run68013.By Kamran Karimi.simulates 11 68020 instructions. 
  2. ;Including: bra.l, extb.l, cas, pack, unpk, link.l, movec, rtd, moves,
  3. ;           move ccr,<ea> and trapcc.
  4. ;Assembled with AssemPro (Profimat) assembler using an standard A500.
  5.  
  6.  
  7. ExecBase    equ 4
  8. Allocmem    equ -198
  9. Open        equ -30
  10. Close       equ -36
  11. Read        equ -42
  12. Write       equ -48
  13. OpenLib     equ -408
  14. CloseLib    equ -414
  15. GetMsg      equ -372
  16. OpenWindow  equ -204
  17. CloseWindow equ -72
  18. WaitPort    equ -384
  19. FindTask    equ -294
  20. Forbid      equ -132
  21. Permit      equ -138
  22.  
  23.  
  24. CLI_WB:                   ;We must determine where we started from
  25.  move.l  ExecBase,a6
  26.  move.l  #0,a1
  27.  jsr     FindTask(a6)
  28.  move.l  d0,a2
  29.  tst.l   $ac(a2)
  30.  bne     FromCLI
  31.  lea     $5c(a2),a0    ;we started from workbench
  32.  jsr     WaitPort(a6)  ;get the wb message but we do not use it
  33.  lea     $5c(a2),a0
  34.  jsr     GetMsg(a6)
  35.  
  36. FromCLI:
  37.  move.l  #20,DOSResult   ;DOSResult will give a return value to DOS
  38. Open_DOS:             ;we'll open dos.library
  39.  lea     DOS_Name,a1
  40.  moveq   #0,d0          ;any version
  41.  jsr     OpenLib(a6)
  42.  move.l  d0,DOS_Base
  43.  beq     No_DOS        ;if coud not open DOS. we should exit!
  44. Window_Opening:
  45.  moveq   #0,d0
  46.  move.w  $128(a6),d0
  47.  move.l  DOS_Base,a6
  48.  andi.w  #$000f,d0
  49.  beq     My68000
  50.  move.l  #Consolename1,d1   ;opening awindow
  51.  move.l  #1005,d2        ;mode_old
  52.  jsr     Open(a6)
  53.  move.l  d0,Window_Handler1
  54.  beq     Close_DOS
  55.  move.l  d0,d1
  56.  move.l  #texte1,d2
  57.  move.l  #textend1-texte1,d3
  58.  jsr     Write(a6)          ;write introduction text
  59.  move.l  Window_Handler1,d1
  60.  move.l  #inbuff,d2
  61.  jsr     Read(a6)           ;wait for user to press return
  62.  move.l  Window_Handler1,d1
  63.  jsr     Close(a6)       ;close CON
  64.  bra     Close_DOS
  65.  
  66. My68000:
  67.  move.l  #Consolename2,d1   ;opening awindow
  68.  move.l  #1005,d2        ;mode_old
  69.  jsr     Open(a6)
  70.  move.l  d0,Window_Handler2
  71.  beq     Close_DOS               ;if could noy open CON, then exit
  72.  move.l  Window_Handler2,d1
  73.  move.l  #texte2,d2
  74.  move.l  #textend2-texte2,d3
  75.  jsr     Write(a6)          ;write introduction text
  76.  move.l  #inbuff,d2
  77.  move.l  Window_Handler2,d1
  78.  jsr     Read(a6)           ;read the user's choice to install the code
  79.  moveq   #0,d1
  80.  move.b  inbuff,d1
  81.  cmpi.b  #'i',d1       ;is it 'i' ?
  82.  beq     Install
  83.  cmpi.b  #'I',d1       ;or 'I' ?
  84.  bne     Done         ;if not equal exit
  85. Install:
  86.  move.l  ExecBase,a6
  87.  jsr     Forbid(a6)
  88.  move.l  #EndAddr-BeginAddr,d0  ; length  of actual code in d0 moveq   #0,d1
  89.  jsr     Allocmem(a6)   ;allocate mem
  90.  move.l  d0,NewAddrExcept
  91.  beq     NoMem
  92.  move.l  $c,OldAddrExcept  ;save the original 'address error' address
  93.  movea.l #BeginAddr,a0
  94.  movea.l NewAddrExcept,a1
  95.  move.l  #EndAddr-BeginAddr,d0
  96.  sub.l   #1,d0
  97. copyaddr:
  98.  move.b  (a0)+,(a1)+    ;copy our exception code to the allocated mem
  99.  dbf     d0,copyaddr
  100.  move.l  #EndIllegal-BeginIllegal,d0  ; length  of actual code in d0
  101.  moveq   #0,d1
  102.  jsr     Allocmem(a6)   ;allocate mem
  103.  move.l  d0,NewIllegalExcept
  104.  beq     NoMem
  105.  move.l  #1024,d0      ;there are 255 longword vector addresses
  106.  moveq   #0,d1
  107.  move.l  ExecBase,a6
  108.  jsr     Allocmem(a6)
  109.  move.l  d0,NewVec     ;address of the copied original vectors
  110.  beq     NoMem
  111.  move.l  $10,OldIllegalExcept  ;save the original 'illegal instruction' address
  112.  movea.l #BeginIllegal,a0
  113.  movea.l NewIllegalExcept,a1
  114.  move.l  #EndIllegal-BeginIllegal,d0
  115.  sub.l   #1,d0
  116. copy:
  117.  move.b  (a0)+,(a1)+    ;copy our exception code to the allocated mem
  118.  dbf     d0,copy
  119.  move.l  NewAddrExcept,$c
  120.  move.l  NewIllegalExcept,$10
  121.  move.l  #1023,d0
  122.  movea.l #0,a0
  123.  movea.l NewVec,a1
  124. copy2:
  125.  move.b  (a0)+,(a1)+   ;get a copy of all the vector area contents
  126.  dbf     d0,copy2  
  127.  jsr     Permit(a6)
  128.  move.l  DOS_Base,a6
  129.  move.l  Window_Handler2,d1
  130.  move.l  #text3,d2
  131.  move.l  #textend3-text3,d3
  132.  jsr     Write(a6)            ;write 'Now you can use ... '
  133.  move.l  #inbuff,d2
  134.  move.l  Window_Handler2,d1
  135.  jsr     Read(a6)           ;wait for user to press return
  136.  move.l  #0,DOSResult
  137.  bra     Done
  138.  
  139. NoMem:
  140.  move.l  ExecBase,a6
  141.  jsr     Permit(a6)
  142. Done:
  143.  move.l  Window_Handler2,d1 
  144.  move.l  DOS_Base,a6
  145.  jsr     Close(a6)       ;close CON
  146.  
  147. Close_DOS:
  148.  move.l  DOS_Base,a1
  149.  move.l  ExecBase,a6
  150.  jsr     CloseLib(a6)    ;close DOS
  151. No_DOS: 
  152.  move.l  DOSResult,d0
  153.  rts
  154.  
  155. Consolename1:  dc.b 'CON:80/40/470/80/Run68013',0
  156. Consolename2:  dc.b 'CON:40/40/550/110/Run68013',0,0
  157. DOS_Name:      dc.b 'dos.library',0
  158.  
  159. texte1:
  160.  dc.b '                     Run68013 ',13,10
  161.  dc.b '             Written By Kamran Karimi',13,10
  162.  dc.b ' This program should only be run on 68000 machines!'
  163.  dc.b 13,10,13,10
  164.  dc.b ' Aborting...',13,10,13,10
  165.  dc.b '                  Press Return to quit...'
  166.  ds.w 0
  167. textend1:
  168.  
  169. texte2:
  170.  dc.b '                               Run68013',13,10
  171.  dc.b '                      Written By Kamran Karimi',13,10 
  172.  dc.b 'This program allows to use some 68020 instructions on a 68000.',13,10
  173.  dc.b 'Refer to the Run68013.ReadMe file for more information',13,10
  174.  dc.b 'It uses self-modifying code so do not run it if you have a cache'
  175.  dc.b 13,10,13,10
  176.  dc.b 'Enter i to install the code, or Return to quit without installing'
  177.  dc.b 13,10,13,10
  178.  dc.b 'Enter i to install:'
  179.  ds.w 0
  180. textend2:
  181.  
  182. text3:
  183.  dc.b 13,10,'Now you can use the additional instructions!',13,10
  184.  dc.b '   Press Return...',0
  185.  ds.w 0
  186. textend3:
  187.  
  188.  
  189. DOS_Base:        dc.l 0
  190. Window_Handler1: dc.l 0
  191. Window_Handler2: dc.l 0
  192. DOSResult:       dc.l 0
  193. inbuff:          dc.b 0,0
  194.  
  195.  
  196. BeginAddr:
  197.  movem.l d0/d1/a0/a1/a6,-(a7)
  198.  move.l  ExecBase,a6
  199.  jsr     Forbid(a6)
  200.  movea.l 30(a7),a0
  201.  move.l  a0,d0
  202.  lsr.l   #1,d0
  203.  bcs     OddAddr
  204.  suba.l  #2,a0
  205.  bra     TestAddr
  206. OddAddr:
  207.  suba.l  #1,a0
  208. TestAddr:
  209.  move.w  (a0),d0
  210.  cmpi.w  #$60ff,d0
  211.  beq     B_R_A_L
  212.  bra     IllegaleAddr
  213.  
  214. B_R_A_L:
  215.  movea.l 30(a7),a0
  216.  move.l  (a0),d0
  217.  adda.l  d0,a0
  218.  move.l  a0,30(a7)
  219.  jsr     Permit(a6)
  220.  movem.l (a7)+,d0/d1/a0/a1/a6
  221.  adda.l  #8,a7         ;remove address error stack frame
  222.  rte
  223.  
  224.  
  225. IllegaleAddr:
  226.  jsr     Permit(a6)
  227.  movem.l (a7)+,d0/d1/a0/a1/a6
  228.  move.l  OldAddrExcept(pc),-(a7) ;place address of original except handler
  229.  suba.l  #2,a7                   ;as return address on the stack
  230.  move.w  14(a7),(a7)
  231.  move.l  d0,-(a7)
  232.  move.w  4(a7),d0
  233.  bset    #13,d0
  234.  bclr    #15,d0
  235.  move.w  d0,4(a7)
  236.  move.l  (a7)+,d0
  237.  rte
  238.  
  239. OldAddrExcept:  dc.l 0
  240. NewAddrExcept:  dc.l 0
  241.  
  242. EndAddr:
  243.  
  244.  
  245. BeginIllegal:        ;determining which command caused exception
  246.  movem.l d0-d7/a0-a6,-(a7)
  247.  move.l  ExecBase,a6
  248.  jsr     Forbid(a6)
  249.  movea.l 62(a7),a0
  250.  move.w  (a0),d3
  251.  move.w  d3,d4
  252.  andi.w  #$f9c0,d3
  253.  cmpi.w  #$08c0,d3
  254.  beq     C_A_S       ;was it CAS
  255.  move.w  d4,d3
  256.  andi.w  #$f1f0,d3
  257.  cmpi.w  #$8180,d3
  258.  beq     U_N_P_K
  259.  move.w  d4,d3
  260.  andi.w  #$f1f0,d3
  261.  cmpi.w  #$8140,d3
  262.  beq     P_A_C_K
  263.  move.w  d4,d3
  264.  andi.w  #$fff8,d3
  265.  cmpi.w  #$4808,d3
  266.  beq     L_I_N_K_L
  267.  move.w  d4,d3
  268.  andi.w  #$f0f8,d3
  269.  cmpi.w  #$50f8,d3     ;TRAPcc ?
  270.  beq     T_R_A_P_C_C
  271.  move.w  d4,d3
  272.  andi.w  #$fe00,d3
  273.  cmpi.w  #$4800,d3     ;EXTB ?
  274.  beq     E_X_T_B
  275.  move.w  d4,d3
  276.  cmpi.w  #$4e74,d3   ;was is RTD?
  277.  beq     R_T_D
  278.  lsr.w   #1,d3
  279.  cmpi.w  #$273d,d3     ;or MOVEC?
  280.  bne     what1
  281.  move.w  60(a7),d0  ;get status register
  282.  btst    #13,d0  ;check if we were in supervisor mode when exception occured
  283.  bne     M_O_V_E_C
  284.  jsr     Permit(a6)
  285.  movem.l (a7)+,d0-d7/a0-a6
  286.  move.l  $20,-(a7)           ;making a fake return address and SR on stack
  287.  suba.l  #2,a7
  288.  move.w  $6(a7),(a7)
  289.  move.l  d0,-(a7)
  290.  move.w  4(a7),d0
  291.  bset    #13,d0    ;supervisor mode
  292.  bclr    #15,d0    ;no trace
  293.  move.w  d0,4(a7)
  294.  move.l  (a7)+,d0
  295.  rte
  296. what1:
  297.  move.w  d4,d3
  298.  lsr.w   #8,d3
  299.  cmpi.w  #$0e,d3    ;was the illegal command MOVES?
  300.  bne     what2
  301.  move.w  60(a7),d0
  302.  btst    #13,d0      ;in supervisor mode
  303.  bne     M_O_V_E_S
  304.  jsr     Permit(a6)
  305.  movem.l (a7)+,d0-d7/a0-a6
  306.  move.l  $20,-(a7)    ;making a fake return address and SR on stack
  307.  suba.l  #2,a7
  308.  move.w  $6(a7),(a7)
  309.  move.l  d0,-(a7)
  310.  move.w  4(a7),d0
  311.  bset    #13,d0    ;supervisor mode
  312.  bclr    #15,d0    ;no trace
  313.  move.w  d0,4(a7)
  314.  move.l  (a7)+,d0
  315.  rte
  316. what2:
  317.  move.w  d4,d3
  318.  lsr.w   #6,d3
  319.  cmpi.w  #$010b,d3         ;was the instruction move ccr,<ea> ?
  320.  beq     M_O_V_E_F_C_C_R
  321.  
  322. illegale:      ;it was non of them so do the usual exception processing
  323.  jsr     Permit(a6)
  324.  movem.l (a7)+,d0-d7/a0-a6
  325.  move.l  OldIllegalExcept(pc),-(a7) ;place address of original except handler
  326.  suba.l  #2,a7                  ;as return address on the stack
  327.  move.w  $6(a7),(a7)
  328.  move.l  d0,-(a7)
  329.  move.w  4(a7),d0
  330.  bset    #13,d0
  331.  bclr    #15,d0
  332.  move.w  d0,4(a7)
  333.  move.l  (a7)+,d0
  334.  rte
  335.  
  336.  
  337.  
  338. C_A_S:
  339.  move.l  62(a7),a0
  340.  move.w  (a0),d1
  341.  move.w  d1,d2
  342.  andi.w  #$0600,d1
  343.  lsr.w   #5,d1
  344.  lsr.w   #4,d1
  345.  move.w  #0,d3
  346.  cmpi.w  #1,d1
  347.  beq     adjsize
  348. longword:
  349.  cmpi.w  #2,d1
  350.  bne     lng
  351.  move.w  #3,d1
  352.  move.w  #1,d3
  353.  bra     adjsize
  354. lng:
  355.  move.w  #2,d1
  356.  move.w  #2,d3
  357. adjsize:
  358.  lsl.w   #7,d1
  359.  lsl.w   #5,d1
  360.  lsl.w   #6,d3
  361.  lea     EffAddr(pc),a3
  362.  andi.w  #$cfff,(a3)
  363.  or.w    d1,(a3)
  364.  lea     Mov(pc),a3
  365.  andi.w  #$cfff,(a3)
  366.  or.w    d1,(a3)
  367.  lea     Comp(pc),a3
  368.  andi.w  #$fe3f,(a3)
  369.  or.w    d3,(a3)
  370.  lea     Movd0(pc),a3
  371.  andi.w  #$cfff,(a3)
  372.  or.w    d1,(a3)
  373.  move.w  d2,d1
  374.  andi.w  #$003f,d1
  375.  lea     EffAddr(pc),a3
  376.  andi.w  #$ffc0,(a3)
  377.  or.w    d1,(a3)
  378.  andi.w  #$7,d1
  379.  andi.w  #$38,d2
  380.  lsl.w   #2,d1
  381.  lsl.w   #7,d1
  382.  lsl.w   #3,d2
  383.  or.w    d2,d1
  384.  lea     Mov(pc),a3
  385.  move.l  #$4e714e71,2(a3)
  386.  lea     EffAddr(pc),a6
  387.  move.l  #$4e714e71,2(a6)
  388.  andi.w  #$f03f,(a3)
  389.  or.w    d1,(a3)
  390.  lsr.w   #6,d2
  391.  cmpi.w  #$5,d2
  392.  bne     tst21
  393.  lea     NumAdd(pc),a4
  394.  move.l  #6,(a4)       ;it is address reg. indirect with displ.
  395.  move.w  4(a0),2(a3)
  396.  move.w  4(a0),2(a6)
  397.  bra     Here71
  398. tst21:
  399.  lsr.w   #6,d1
  400.  cmpi.w  #$7,d1
  401.  bne     tst31
  402.  lea     NumAdd(pc),a4
  403.  move.l  #6,(a4)
  404.  move.w  4(a0),2(a3)
  405.  move.w  4(a0),2(a6)
  406.  bra     Here71
  407. tst31:
  408.  cmpi.w  #$f,d1
  409.  bne     tst41
  410.  lea     NumAdd(pc),a4
  411.  move.l  #8,(a4)
  412.  move.l  4(a0),2(a3)
  413.  move.l  4(a0),2(a6)
  414.  bra     Here71
  415. tst41:
  416.  lea     NumAdd(pc),a4
  417.  move.l  #4,(a4)
  418. Here71:
  419.  move.l  62(a7),a0
  420.  move.w  2(a0),d4
  421.  move.w  d4,d5
  422.  andi.w  #$7,d4
  423.  lsl.w   #7,d4
  424.  lsl.w   #2,d4
  425.  lea     Comp(pc),a3
  426.  andi.w  #$f1ff,(a3)
  427.  or.w    d4,(a3)
  428.  andi.w  #$01c0,d5
  429.  lsr.w   #6,d5
  430.  lea     Mov(pc),a3
  431.  andi.w  #$fff8,(a3)
  432.  or.w    d5,(a3)
  433.  lea     saveA7(pc),a3
  434.  move.l  a7,(a3)
  435.  movem.l (a7)+,d0-d7/a0-a6
  436.  lea     saved1(pc),a7
  437.  move.l  d0,(a7)
  438. EffAddr:
  439.  move.l  d0,d0     ;move <ea> to savea1
  440.  nop
  441.  nop
  442.  lea     savea1(pc),a7
  443. Movd0:
  444.  move.l  d0,(a7)
  445.                     ;place the operand in savea1
  446.  move.l  saved1(pc),d0
  447. Comp:
  448.  cmp.l   savea1(pc),d0    ;compare savea1 to dc
  449.  lea     SaveVal(pc),a7
  450.  move    SR,(a7)
  451.  bne     NotEQ
  452. Mov:
  453.  move.l  d0,d0     ;move du to <ea>
  454.  nop
  455.  nop
  456. NotEQ:
  457.  move.l  saveA7(pc),a7
  458.  adda.l  #60,a7
  459.  movem.l d0-d7/a0-a6,-(a7)
  460.  move.w  SaveVal(pc),d3
  461.  andi.w  #$000f,d3
  462.  move.w  60(a7),d2
  463.  andi.w  #$fff0,d2
  464.  or.w    d2,d3
  465.  move.w  d3,60(a7)
  466.  move.l  62(a7),d4
  467.  add.l   NumAdd(pc),d4
  468.  move.l  d4,62(a7)
  469.  move.l  ExecBase,a6
  470.  jsr     Permit(a6)
  471.  movem.l (a7)+,d0-d7/a0-a6
  472.  rte
  473.  
  474.   
  475.   
  476.  
  477. U_N_P_K:
  478.  move.l  62(a7),a0
  479.  move.w  (a0),d1
  480.  move.w  d1,d2
  481.  andi.w  #$8,d1
  482.  beq     datareg
  483.  move.w  #32,d3
  484.  bra     lab10
  485. datareg:
  486.  move.w  #0,d3
  487. lab10:
  488.  move.w  d2,d1
  489.  andi.w  #$7,d1 
  490.  or.w    d3,d1    ;get source
  491.  lea     Source(pc),a1
  492.  andi.w  #$ffc0,(a1)
  493.  or.w    d1,(a1)
  494.  move.w  d2,d1
  495.  andi.w  #$0e00,d1
  496.  lsl.w   #3,d3
  497.  or.w    d3,d1
  498.  lea     Dest(pc),a1
  499.  andi.w  #$f03f,(a1)
  500.  or.w    d1,(a1)
  501.  lea     saveA7(pc),a3
  502.  move.l  a7,(a3)
  503.  movem.l (a7)+,d0-d7/a0-a6
  504.  lea     SaveVal(pc),a7
  505. Source:
  506.  move.b  d0,(a7)
  507.  move.l  saveA7(pc),a7
  508.  adda.l  #60,a7
  509.  movem.l d0-d7/a0-a6,-(a7)
  510.  move.b  SaveVal(pc),d5
  511.  move.w  d5,d4
  512.  andi.w  #$000f,d5
  513.  andi.w  #$00f0,d4
  514.  lsl.w   #4,d4
  515.  or.w    d4,d5
  516.  move.l  62(a7),a0
  517.  move.w  2(a0),d1
  518.  add.w   d1,d5
  519.  lea     Dest(pc),a3
  520.  move.w  d5,2(a3)
  521.  movem.l (a7)+,d0-d7/a0-a6
  522. Dest:
  523.  move.w  #$0000,d0
  524.  movem.l d0/d1/a0/a1/a6,-(a7)
  525.  move.l  ExecBase,a6
  526.  jsr     Permit(a6)
  527.  move.l  22(a7),d0
  528.  add.l   #4,d0
  529.  move.l  d0,22(a7)
  530.  movem.l (a7)+,d0/d1/a0/a1/a6
  531.  rte
  532.  
  533.  
  534.  
  535. P_A_C_K:
  536.  move.l  62(a7),a0
  537.  move.w  (a0),d1
  538.  move.w  d1,d2
  539.  andi.w  #$8,d1
  540.  beq     datareg20
  541.  move.w  #32,d3
  542.  bra     lab100
  543. datareg20:
  544.  move.w  #0,d3
  545. lab100:
  546.  move.w  d2,d1
  547.  andi.w  #$7,d1 
  548.  or.w    d3,d1    ;get source
  549.  lea     Source20(pc),a1
  550.  andi.w  #$ffc0,(a1)
  551.  or.w    d1,(a1)
  552.  move.w  d2,d1
  553.  andi.w  #$0e00,d1
  554.  lsl.w   #3,d3
  555.  or.w    d3,d1
  556.  lea     Dest20(pc),a1
  557.  andi.w  #$f03f,(a1)
  558.  or.w    d1,(a1)
  559.  lea     saveA7(pc),a3
  560.  move.l  a7,(a3)
  561.  movem.l (a7)+,d0-d7/a0-a6
  562.  lea     SaveVal(pc),a7
  563. Source20:
  564.  move.w  d0,(a7)
  565.  move.l  saveA7(pc),a7
  566.  adda.l  #60,a7
  567.  movem.l d0-d7/a0-a6,-(a7)
  568.  move.w  SaveVal(pc),d5
  569.  move.l  62(a7),a0
  570.  move.w  2(a0),d1
  571.  add.w   d1,d5
  572.  move.w  d5,d6
  573.  andi.w  #$0f00,d6
  574.  lsr.w   #4,d6
  575.  andi.w  #$000f,d5
  576.  or.w    d6,d5
  577.  lea     Dest20(pc),a3
  578.  move.w  d5,2(a3)
  579.  movem.l (a7)+,d0-d7/a0-a6
  580. Dest20:
  581.  move.b  #00,d0
  582.  movem.l d0/d1/a0/a1/a6,-(a7)
  583.  move.l  ExecBase,a6
  584.  jsr     Permit(a6)
  585.  move.l  22(a7),d0
  586.  add.l   #4,d0
  587.  move.l  d0,22(a7)
  588.  movem.l (a7)+,d0/d1/a0/a1/a6
  589.  rte
  590.  
  591.  
  592.  
  593.  
  594. L_I_N_K_L:
  595.  move.l  62(a7),a0
  596.  move.w  (a0),d1
  597.  andi.w  #$0007,d1
  598.  lea     RetAddr(pc),a3
  599.  move.l  62(a7),(a3)
  600.  lea     MySR(pc),a3
  601.  move.w  60(a7),d0
  602.  move.w  d0,(a3)
  603.  btst    #13,d0
  604.  bne     SuperS1
  605.  move    USP,a1
  606.  lea     savea1(pc),a3  ;save USP
  607.  move.l  a1,(a3)
  608.  suba.l  #4,a1
  609.  lea     MySP(pc),a3
  610.  move    a1,USP
  611.  move.l  a1,(a3)
  612.  bra     DoOr
  613. SuperS1:
  614.  lea     savea1(pc),a3
  615.  move.l  a7,d5
  616.  move.l  d5,(a3)
  617.  add.l   #66,(a3)    ;66 - 4 = 62
  618.  lea     MySP(pc),a3
  619.  move.l  d5,(a3)
  620.  add.l   #62,(a3)
  621. DoOr:
  622.  cmpi.w  #1,d1
  623.  beq     lab2
  624.  lea     mova1(pc),a2
  625.  andi.w  #$fff8,(a2)
  626.  or.w    d1,(a2)+
  627.  lsl.w   #7,d1
  628.  lsl.w   #2,d1
  629.  andi.w  #$f0ff,(a2)
  630.  or.w    d1,(a2)
  631.  lea     saveA7(pc),a3
  632.  move.l  a7,(a3)            ;save a7
  633.  movem.l (a7)+,d0-d7/a0-a6
  634.  lea     saved1(pc),a7
  635.  move.l  a1,(a7)
  636.  movea.l savea1(pc),a1
  637. mova1:
  638.  move.l  a0,-(a1)
  639.  movea.l MySP(pc),a0
  640.  movea.l saved1(pc),a1
  641.  bra     lab1
  642. lab2:
  643.  lea     saveA7(pc),a3
  644.  move.l  a7,(a3)            ;save a7
  645.  movem.l (a7)+,d0-d7/a0-a6
  646.  lea     saved1(pc),a7
  647.  move.l  a0,(a7)
  648.  movea.l savea1(pc),a0
  649. mova0:
  650.  move.l  a1,-(a0)
  651.  movea.l MySP(pc),a1
  652.  movea.l saved1(pc),a0
  653. lab1:
  654.  movea.l saveA7(pc),a7
  655.  adda.l  #60,a7
  656.  movem.l d0-d7/a0-a6,-(a7)
  657.  movea.l RetAddr(pc),a0
  658.  adda.l  #2,a0
  659.  move.l  (a0),d1
  660.  move.w  MySR(pc),d3
  661.  btst    #13,d3
  662.  bne     SuperS2
  663.  move    USP,a1
  664.  adda.l  d1,a1
  665.  move    a1,USP
  666.  bra     fin
  667. SuperS2:
  668.  lea     saved1(pc),a3
  669.  move.l  d1,(a3)
  670.  movem.l (a7)+,d0-d7/a0-a6
  671.  move.l  MySP(pc),a7
  672.  adda.l  saved1(pc),a7
  673.  move.l  RetAddr(pc),-(a7)
  674.  add.l   #6,(a7)           ;link.l requires 6 bytes.
  675.  move.w  MySR(pc),-(a7)
  676.  movem.l d0/d1/a0/a1/a6,-(a7)
  677.  move.l  ExecBase,a6
  678.  jsr     Permit(a6)
  679.  movem.l (a7)+,d0/d1/a0/a1/a6
  680.  rte
  681. fin:
  682.  move.l  RetAddr(pc),d0
  683.  add.l   #6,d0
  684.  move.l  d0,62(a7)
  685.  move.w  MySR(pc),d0
  686.  move.w  d0,60(a7)
  687.  move.l  ExecBase,a6
  688.  jsr     Permit(a6)
  689.  movem.l (a7)+,d0-d7/a0-a6
  690.  rte
  691.  
  692.  
  693. T_R_A_P_C_C:
  694.  move.l  62(a7),a0
  695.  move.w  (a0),d0
  696.  move.w  d0,d4
  697.  andi.w  #$0f00,d0
  698.  cmpi.w  #$0000,d0
  699.  beq     GoTrap
  700.  cmpi.w  #$0100,d0
  701.  seq     d5
  702.  lea     bcond(pc),a1
  703.  andi.w  #$f0ff,(a1)
  704.  or.w    d0,(a1)
  705.  andi.w  #$0007,d4
  706.  cmpi.w  #4,d4       ;has a operand
  707.  bne     HasOp
  708.  moveq   #2,d6
  709.  bra     OpFound
  710. HasOp:
  711.  cmpi.w  #2,d4    ;is the operand word?
  712.  bne     long
  713.  moveq   #4,d6
  714.  bra     OpFound
  715. long:
  716.  cmpi.w  #3,d4
  717.  beq     Found
  718.  bra     illegale
  719. Found:
  720.  moveq   #6,d6
  721.  tst.b   d5
  722.  beq     Exit1
  723. OpFound:
  724.  lea     bcond(pc),a2
  725.  move.l  a2,-(a7)
  726.  move.w  64(a7),d2
  727.  bset    #13,d2
  728.  bclr    #15,d2
  729.  move.w  d2,-(a7)
  730.  rte
  731.  nop             ;force the cpu to use the original status register
  732. bcond:
  733.  bcs     GoTrap
  734. Exit1:
  735.  move.l  62(a7),d4         
  736.  add.l   d6,d4
  737.  move.l  d4,62(a7)
  738.  move.l  ExecBase,a6
  739.  jsr     Permit(a6)
  740.  movem.l (a7)+,d0-d7/a0-a6
  741.  rte
  742. GoTrap:
  743.  move.l  62(a7),d2
  744.  add.l   d6,d2
  745.  move.l  d2,62(a7)
  746.  move.l  ExecBase,a6
  747.  jsr     Permit(a6)
  748.  movem.l (a7)+,d0-d7/a0-a6
  749.  move.l  $1c,-(a7) ;place address of original except handler
  750.  suba.l  #2,a7                  ;as return address on the stack
  751.  move.w  $6(a7),(a7)
  752.  move.l  d0,-(a7)
  753.  move.w  4(a7),d0
  754.  bset    #13,d0
  755.  bclr    #15,d0
  756.  move.w  d0,4(a7)
  757.  move.l  (a7)+,d0
  758.  rte
  759.  
  760.  
  761.  
  762.  
  763. E_X_T_B:
  764.  move.l  62(a7),a0
  765.  move.w  (a0),d1
  766.  lea     extw(pc),a1
  767.  andi.w  #$fff8,(a1)
  768.  andi.w  #$0007,d1
  769.  or.w    d1,(a1)
  770.  lea     extl(pc),a1
  771.  andi.w  #$fff8,(a1)
  772.  or.w    d1,(a1)
  773.  movem.l (a7)+,d0-d7/a0-a6
  774. extw:
  775.  ext.w   d0
  776. extl:
  777.  ext.l   d0
  778.  movem.l d0-d7/a0-a6,-(a7)
  779.  move    SR,d0
  780.  andi.w  #$000f,d0
  781.  move.w  60(a7),d1
  782.  andi.w  #$fff0,d1
  783.  or.w    d0,d1
  784.  move.w  d1,60(a7)
  785.  move.l  62(a7),d4         ;get the address of the extb.l instruction
  786.  add.l   #2,d4       ;add 2 so that execution begins with the next opcode
  787.  move.l  d4,62(a7)
  788.  move.l  ExecBase,a6
  789.  jsr     Permit(a6)
  790.  movem.l (a7)+,d0-d7/a0-a6
  791.  rte
  792.  
  793.  
  794. R_T_D:      ;Syntax: rtd  #<data>
  795.  move.l  62(a7),a0
  796.  adda.l  #2,a0
  797.  moveq   #0,d0
  798.  move.w  (a0),d0    ;d0 = #<data>
  799.  move.w  60(a7),d1
  800.  btst    #13,d1         ;which stack we were using befor the exception?
  801.  bne     SuperStack
  802.  move.l  usp,a6
  803.  move.l  (a6)+,62(a7)  ;place return address on the usp as the except return
  804.  adda.l  d0,a6        ;address on top of the ssp so we'll return there
  805.                ;then add  the number of bytes appropriate to the usp
  806.  move.l  a6,usp
  807.  bra     EndIt
  808. SuperStack:
  809.  move.l  a7,a6
  810.  adda.l  #70,a6 ;60=15 regs*4,2 for SR,4 for illegal inst,addr,4for ret addr
  811.  adda.l  d0,a6
  812.  move.l  66(a7),-(a6)  ;retun address for rtd
  813.  move.w  60(a7),-(a6)  ;SR
  814.  move.l  #14,d4       ;15 regs
  815.  adda.l  #60,a7
  816. cop:
  817.  move.l  -(a7),-(a6)
  818.  dbra    d4,cop
  819.  move.l  a6,a7
  820. EndIt:
  821.  move.l  ExecBase,a6
  822.  jsr     Permit(a6)
  823.  movem.l (a7)+,d0-d7/a0-a6
  824.  rte
  825.  
  826.  
  827. M_O_V_E_C:   ;Syntax:movec CR,Rn or movec Rn,CR (CR=a control register)
  828.  move.l  62(a7),a0
  829.  move.w  (a0),d3  ;this is the illegal instruction
  830.  btst    #0,d3
  831.  bne     ToCR
  832.  move.w  2(a0),d3
  833.  move.w  d3,d4
  834.  lea     Source2(pc),a3
  835.  andi.w  #$f03f,(a3)
  836.  btst    #15,d3
  837.  beq     Datareg2
  838.  andi.w  #$7000,d3
  839.  lsr.w   #3,d3
  840.  ori.w   #$0040,d3
  841.  or.w    d3,(a3)
  842.  bra     lab20
  843. Datareg2:
  844.  andi.w  #$7000,d3
  845.  lsr.w   #3,d3
  846.  or.w    d3,(a3)
  847. lab20:
  848.  andi.w  #$0fff,d4     ;get the control register
  849.  cmpi.w  #$0,d4        ;is it SFC?
  850.  bne     nextt1
  851.  movea.l MySFC(pc),a1     ;put its contents in a1
  852.  bra     Here1
  853. nextt1:
  854.  cmpi.w  #$0001,d4     ;is it DFC?
  855.  bne     nextt2
  856.  movea.l MyDFC(pc),a1    ;put it in a1
  857.  bra     Here1
  858. nextt2:
  859.  cmpi.w  #$0800,d4     ;is it USP?
  860.  bne     nextt3
  861.  move    USP,a1        ;put it in a1
  862.  bra     Here1
  863. nextt3:
  864.  cmpi.w  #$0002,d4     ;is it CACR?
  865.  bne     nextt4
  866.  movea.l MyCACR(pc),a1        ;put it in a1
  867.  bra     Here1
  868. nextt4:
  869.  cmpi.w  #$0802,d4     ;is it CAAR?
  870.  bne     nextt5
  871.  movea.l MyCAAR(pc),a1        ;put it in a1
  872.  bra     Here1
  873. nextt5:
  874.  cmpi.w  #$0803,d4     ;is it MSP?
  875.  beq     ssp1
  876.  cmpi.w  #$0804,d4    ;or ISP?
  877.  bne     nextt6
  878. ssp1:
  879.  movea.l a7,a1
  880.  adda.l  #66,a1       ;don't consider the pushed registers!
  881.  bra     Here1
  882. nextt6:
  883.  cmpi.w  #$0801,d4
  884.     ;is it VBR?
  885.  beq     mvbr
  886.  bra     illegale
  887. mvbr:
  888.  movea.l MyVBR(pc),a1    ; put it in a1
  889. Here1:
  890.  lea     SaveVal(pc),a3
  891.  move.l  a1,(a3)
  892.  movem.l (a7)+,d0-d7/a0-a6
  893. Source2:
  894.  move.l  SaveVal(pc),d0
  895.  movem.l d0-d7/a0-a6,-(a7)
  896.  move.l  62(a7),d4         ;get the address of the movec instruction
  897.  add.l   #4,d4       ;add 4 so that execution begins with the next opcode
  898.  move.l  d4,62(a7)
  899.  move.l  ExecBase,a6
  900.  jsr     Permit(a6)
  901.  movem.l (a7)+,d0-d7/a0-a6
  902.  rte
  903.  
  904. ToCR:
  905.  move.w  2(a0),d3
  906.  move.w  d3,d4
  907.  lea     Source3(pc),a3
  908.  andi.w  #$ffc0,(a3)
  909.  btst    #15,d3
  910.  beq     Datareg3
  911.  andi.w  #$7000,d3
  912.  lsr.w   #5,d3
  913.  lsr.w   #7,d3
  914.  ori.w   #$0008,d3
  915.  or.w    d3,(a3)
  916.  bra     lab30
  917. Datareg3:
  918.  andi.w  #$7000,d3
  919.  lsr.w   #5,d3
  920.  lsr.w   #7,d3
  921.  or.w    d3,(a3)
  922. lab30:
  923.  lea     saveA7(pc),a3
  924.  move.l  a7,(a3)
  925.  lea     saved1(pc),a3
  926.  move.l  d4,(a3)
  927.  movem.l (a7)+,d0-d7/a0-a6
  928.  lea     SaveVal(pc),a7
  929. Source3:
  930.  move.l  d0,(a7)
  931.  move.l  saveA7(pc),a7
  932.  adda.l  #60,a7
  933.  movem.l d0-d7/a0-a6,-(a7)
  934.  move.l  SaveVal(pc),d1
  935.  move.l  saved1(pc),d4
  936.  andi.w  #$0fff,d4
  937.  cmpi.w  #$0,d4
  938.  bne     nextr1
  939.  lea     MySFC(pc),a3
  940.  andi.l  #$7,d1
  941.  move.l  d1,(a3)
  942.  bra     here2
  943. nextr1:
  944.  cmpi.w  #$0001,d4
  945.  bne     nextr2
  946.  lea     MyDFC(pc),a3
  947.  andi.l  #$7,d1
  948.  move.l  d1,(a3)
  949.  bra     here2
  950. nextr2:
  951.  cmpi.w  #$0800,d4
  952.  bne     nextr3
  953.  movea.l d1,a2
  954.  move    a2,USP
  955. nextr3:
  956.  cmpi.w  #$0002,d4
  957.  bne     nextr4
  958.  lea     MyCACR(pc),a3
  959.  andi.l  #$f,d1
  960.  move.l  d1,(a3)
  961.  bra     here2
  962. nextr4:
  963.  cmpi.w  #$0802,d4
  964.  bne     nextr5
  965.  lea     MyCAAR(pc),a3
  966.  move.l  d1,(a3)
  967.  bra     here2
  968. nextr5:
  969.  cmpi.w  #$0803,d4
  970.  beq     ssp2
  971.  cmpi.w  #$0804,d4
  972.  bne     nextr6
  973. ssp2:
  974.  lea     saved1(pc),a3
  975.  move.l  d1,(a3)
  976.  lea     saveA7(pc),a3
  977.  move.l  a7,(a3)
  978.  movem.l (a7)+,d0-d7/a0-a6
  979.  lea     savea1(pc),a7
  980.  move.l  a1,(a7)
  981.  move.l  saved1(pc),a1
  982.  move.l  saveA7(pc),a7
  983.  adda.l  #60,a7
  984.  move.l  2(a7),-(a1)   ;return address
  985.  move.w  (a7),-(a1)   ;status register
  986.  move.l  a1,a7
  987.  move.l  savea1(pc),a1
  988.  movem.l d0-d7/a0-a6,-(a7)
  989.  bra     here2
  990. nextr6:
  991.  cmpi.w  #$0801,d4
  992.  beq     mvbr2
  993.  bra     illegale
  994. mvbr2:
  995.  lea     MyVBR(pc),a3
  996.  move.l  d1,(a3)
  997.  bne     NotZero   ;if new address not zero then copy the 1024 bytes at the
  998.  movea.l #0,a5         ;VBR address to the locations 0-1024
  999.  movea.l NewVec(pc),a4
  1000.  move.l  #1023,d4
  1001. copy3:
  1002.  move.b  (a4)+,(a5)+
  1003.  dbf     d4,copy3
  1004.  bra     here2
  1005. NotZero:
  1006.  movea.l MyVBR(pc),a4 ;if the VBR holds 0,then copy the original vectors in
  1007.  movea.l #0,a5      ;in its place
  1008.  move.l  #1023,d4
  1009. copy4:
  1010.  move.b  (a4)+,(a5)+
  1011.  dbf     d4,copy4
  1012. here2:
  1013.  move.l  62(a7),d4
  1014.  add.l   #4,d4
  1015.  move.l  d4,62(a7)
  1016.  move.l  ExecBase,a6
  1017.  jsr     Permit(a6)
  1018.  movem.l (a7)+,d0-d7/a0-a6
  1019.  rte
  1020.  
  1021.  
  1022.  
  1023. M_O_V_E_S:       ;Syntax:moves Rn,<ea> or moves <ea>,Rn
  1024.  move.l  62(a7),a0
  1025.  adda.l  #2,a0    ;address of the second word of operand
  1026.  move.w  (a0),d3
  1027.  btst    #11,d3
  1028.  beq     ea2Rn
  1029.            ;this is moves.x  Rn,<ea>.first move.x Rn,d0 then move.x d0,<ea>
  1030.  moveq   #0,d2      ;we will produce the opcode in d2
  1031.  movea.l 62(a7),a0
  1032.  move.w  (a0),d3    ;first word in d3
  1033.  andi.w  #$00c0,d3     ;determine operation size (.B, .W or .L)
  1034.  lsr.w   #6,d3
  1035.  cmpi.w  #0,d3
  1036.  bne     wl
  1037.  move.w  #$1000,d2
  1038.  bra     size1
  1039. wl:               ;Word or Long
  1040.  cmpi.w  #1,d3
  1041.  bne     l
  1042.  move.w  #$3000,d2
  1043.  bra     size1
  1044. l:                 ;Long
  1045.  move.w  #$2000,d2
  1046. size1:
  1047.  adda.l  #2,a0
  1048.  move.w  (a0),d3    ;second word in d3
  1049.  andi.w  #$f000,d3
  1050.  lsr.w   #8,d3
  1051.  lsr.w   #4,d3
  1052.  cmpi.w  #0,d3
  1053.  seq     d6      ;was the Rn, d0? if yes, then set d6 to 1
  1054.  or.w    d3,d2
  1055.  tst.b   d6
  1056.  beq     Notd01
  1057.  movem.l (a7)+,d0-d7/a0-a6
  1058.  movem.l d0-d7/a0-a6,-(a7)
  1059.  lea     saved0(pc),a3
  1060.  move.l  d0,(a3)
  1061.  bra     here3
  1062. Notd01:
  1063.  lea     CRn2d2,a3
  1064.  move.w  d2,(a3)
  1065.  lea     saveA7(pc),a3
  1066.  move.l  a7,(a3)
  1067.  movem.l (a7)+,d0-d7/a0-a6
  1068.  lea     savereg(pc),a7
  1069.  move.l  d0,(a7)
  1070. CRn2d2:  dc.w 0
  1071.  lea     saved0(pc),a7
  1072.  move.l  d0,(a7)
  1073.  move.l  savereg(pc),d0
  1074.  move.l  saveA7(pc),a7
  1075.  adda.l  #60,a7
  1076.  movem.l d0-d7/a0-a6,-(a7)
  1077. here3:
  1078.  moveq   #0,d2
  1079.  movea.l 62(a7),a0
  1080.  move.w  (a0),d3
  1081.  move.w  d3,d4
  1082.  andi.w  #$0007,d3     ;register number of <ea>
  1083.  cmpi.w  #0,d3
  1084.  seq     d5 ;set if register number=0, if mode=7 then it means Absolut short
  1085.  cmpi.w  #1,d3
  1086.  seq     d7 ;if reg num=1 and mode =7 then addressing=absolute long
  1087.  lsl.w   #8,d3
  1088.  lsl.w   #1,d3
  1089.  or.w    d3,d2
  1090.  move.w  d4,d3
  1091.  andi.w  #$0038,d3      ;get the mode in d3 lsr.w   #3,d3
  1092.  cmpi.w  #7,d3
  1093.  seq     d1     ;if mode=1 then set d1 to 1
  1094.  cmpi.w  #5,d3
  1095.  bne     gg1
  1096.  seq     d6   ;if mode=5 then address reg indirect with displacement
  1097.  bra     gg2
  1098. gg1:
  1099.  cmpi.w  #6,d3
  1100.  seq     d6 ;if mode=6 then address reg indirect with index and displacement
  1101. gg2:
  1102.  lsl.w   #6,d3
  1103.  or.w    d3,d2
  1104.  move.w  d4,d3
  1105.  andi.w  #$00c0,d3       ;get size
  1106.  lsr.w   #6,d3
  1107.  cmpi.w  #0,d3
  1108.  bne     wl2
  1109.  ori.w   #$1000,d2
  1110.  bra     size2
  1111. wl2:
  1112.  cmpi.w  #1,d3
  1113.  bne     l2
  1114.  ori.w   #$3000,d2
  1115.  bra     size2
  1116. l2:
  1117.  ori.w   #$2000,d2
  1118. size2:
  1119.  tst.b   d6
  1120.  beq     NoAdind
  1121.  adda.l  #4,a0
  1122.  lea     code32(pc),a3
  1123.  move.w  (a0),(a3)
  1124.  lea     code33(pc),a3
  1125.  move.w  #$4e71,(a3)
  1126.  lea     NumAdd(pc),a3
  1127.  move.l  #6,(a3)
  1128.  bra     GoOn5
  1129. NoAdind:  ;it is no form of address reg indirect with displacement or index
  1130.  tst.b   d1
  1131.  beq     NoExt  ;<ea> has no extention words at all (like (An) or (An)+)
  1132.  tst.b   d5
  1133.  beq     testlong
  1134.  adda.l  #4,a0       ;get the extention word
  1135.  lea     code32(pc),a3
  1136.  move.w  (a0),(a3)       ;move extention word
  1137.  lea     code33(pc),a3
  1138.  move.w  #$4e71,(a3)  ;move NOP
  1139.  lea     NumAdd(pc),a3 ;we must add 6 to the pc to get the next instruction
  1140.  move.l  #6,(a3)
  1141.  bra     GoOn5
  1142. testlong:       ;is it absolute long addressing
  1143.  tst.b   d7
  1144.  bne     NotIll1
  1145.  bra     illegale  ;could not fined a legal addressing
  1146. NotIll1:
  1147.  adda.l  #4,a0
  1148.  lea     code32(pc),a3
  1149.  move.l  (a0),(a3)
  1150.  lea     NumAdd(pc),a3
  1151.  move.l  #8,(a3)
  1152.  bra     GoOn5
  1153. NoExt:
  1154.  lea     code32(pc),a3
  1155.  move.l  #$4e714e71,(a3)  ;move two NOPs
  1156.  lea     NumAdd(pc),a3
  1157.  move.l  #4,(a3)
  1158. GoOn5:
  1159.  lea     code31(pc),a3
  1160.  move.w  d2,(a3)
  1161.  lea     saveA7(pc),a3
  1162.  move.l  a7,(a3)
  1163.  movem.l (a7)+,d0-d7/a0-a6
  1164.  lea     savereg(pc),a7
  1165.  move.l  d0,(a7)
  1166.  move.l  saved0(pc),d0
  1167. code31:  dc.w 0
  1168. code32:  dc.w 0
  1169. code33:  dc.w 0
  1170.  move.l  savereg(pc),d0
  1171.  move.l  saveA7(pc),a7
  1172.  adda.l  #60,a7
  1173.  movem.l d0-d7/a0-a6,-(a7)
  1174.  move.l  62(a7),d4
  1175.  add.l   NumAdd(pc),d4
  1176.  move.l  d4,62(a7)
  1177.  move.l  ExecBase,a6
  1178.  jsr     Permit(a6)
  1179.  movem.l (a7)+,d0-d7/a0-a6
  1180.  rte
  1181.  
  1182. ea2Rn:    ;moves.x <ea>,Rn=move.x <ea>,d0 + move.x d0,Rn
  1183.  moveq   #0,d2
  1184.  movea.l 62(a7),a0
  1185.  move.w  (a0),d3
  1186.  move.w  d3,d4
  1187.  andi.w  #$003f,d3
  1188.  move.w  d3,d2
  1189.  move.w  d4,d3
  1190.  andi.w  #$0007,d3
  1191.  cmpi.w  #0,d3
  1192.  seq     d5
  1193.  cmpi.w  #1,d3
  1194.  seq     d7
  1195.  move.w  d4,d3
  1196.  andi.w  #$0038,d3
  1197.  lsr.w   #3,d3
  1198.  cmpi.w  #7,d3
  1199.  seq     d1
  1200.  cmpi.w  #5,d3
  1201.  bne     ff1
  1202.  seq     d6
  1203.  bra     ff2
  1204. ff1:
  1205.  cmpi.w  #6,d3
  1206.  seq     d6
  1207. ff2:
  1208.  move.w  d4,d3
  1209.  andi.w  #$00c0,d3
  1210.  lsr.w   #6,d3
  1211.  cmpi.w  #0,d3
  1212.  bne     wl3
  1213.  ori.w   #$1000,d2
  1214.  bra     size3
  1215. wl3:
  1216.  cmpi.w  #1,d3
  1217.  bne     l3
  1218.  ori.w   #$3000,d2
  1219.  bra     size3
  1220. l3:
  1221.  ori.w   #$2000,d2
  1222. size3:
  1223.  tst.b   d6
  1224.  beq     NoAdind2
  1225.  adda.l  #4,a0
  1226.  lea     code42(pc),a3
  1227.  move.w  (a0),(a3)
  1228.  lea     code43(pc),a3
  1229.  move.w  #$4e71,(a3)
  1230.  lea     NumAdd(pc),a3
  1231.  move.l  #6,(a3)
  1232.  bra     GoOn6
  1233. NoAdind2:
  1234.  tst.b   d1
  1235.  beq     NoExt2
  1236.  tst.b   d5
  1237.  beq     testlong2
  1238.  adda.l  #4,a0
  1239.  lea     code42(pc),a3
  1240.  move.w  (a0),(a3)
  1241.  lea     code43(pc),a3
  1242.  move.w  #$4e71,(a3)
  1243.  lea     NumAdd(pc),a3
  1244.  move.l  #6,(a3)
  1245.  bra     GoOn6
  1246. testlong2:
  1247.  tst.b   d7
  1248.  bne     NotIll2
  1249.  bra     illegale
  1250. NotIll2:
  1251.  adda.l  #4,a0
  1252.  lea     code42(pc),a3
  1253.  move.l  (a0),(a3)
  1254.  lea     NumAdd(pc),a3
  1255.  move.l  #8,(a3)
  1256.  bra     GoOn6
  1257. NoExt2:
  1258.  lea     code42(pc),a3
  1259.  move.l  #$4e714e71,(a3)
  1260.  lea     NumAdd(pc),a3
  1261.  move.l  #4,(a3)
  1262. GoOn6:
  1263.  lea     code41(pc),a3
  1264.  move.w  d2,(a3)
  1265.  lea     saveA7(pc),a3
  1266.  move.l  a7,(a3)
  1267.  movem.l (a7)+,d0-d7/a0-a6
  1268.  lea     savereg(pc),a7
  1269.  move.l  d0,(a7)
  1270. code41:  dc.w 0
  1271. code42:  dc.w 0
  1272. code43:  dc.w 0
  1273.  lea     saved0(pc),a7
  1274.  move.l  d0,(a7)
  1275.  move.l  savereg(pc),d0
  1276.  move.l  saveA7(pc),a7
  1277.  adda.l  #60,a7
  1278.  movem.l d0-d7/a0-a6,-(a7)
  1279. here6:
  1280.  moveq   #0,d2
  1281.  movea.l 62(a7),a0
  1282.  move.w  (a0),d3
  1283.  andi.w  #$00c0,d3
  1284.  lsr.w   #6,d3
  1285.  cmpi.w  #0,d3
  1286.  bne     wl4
  1287.  move.w  #$1000,d2
  1288.  bra     size4
  1289. wl4:
  1290.  cmpi.w  #1,d3
  1291.  bne     l4
  1292.  move.w  #$3000,d2
  1293.  bra     size4
  1294. l4:
  1295.  move.w  #$2000,d2
  1296. size4:
  1297.  adda.l  #2,a0
  1298.  move.w  (a0),d3
  1299.  btst    #15,d3
  1300.  seq     d5
  1301.  andi.w  #$7000,d3
  1302.  move.w  d3,d7
  1303.  lsr.w   #8,d7
  1304.  lsr.w   #4,d7
  1305.  lsr.w   #3,d3
  1306.  cmpi.w  #0,d7
  1307.  seq     d6
  1308.  tst.b   d5
  1309.  bne     GoOn4
  1310.  ori.w   #$0040,d3
  1311. GoOn4:
  1312.  or.w    d3,d2
  1313.  tst.b   d6
  1314.  beq     Notd02
  1315.  ori.w   #$0001,d2
  1316.  lea     Cd2Rn1(pc),a3
  1317.  move.w  d2,(a3)
  1318.  lea     saveA7(pc),a3
  1319.  move.l  a7,(a3)
  1320.  movem.l (a7)+,d0-d7/a0-a6
  1321.  lea     savereg(pc),a7
  1322.  move.l  d1,(a7)
  1323.  move.l  saved0(pc),d1
  1324. Cd2Rn1:  dc.w 0
  1325.  move.l  savereg(pc),d1
  1326.  bra     here4
  1327. Notd02:
  1328.  lea     Cd2Rn2(pc),a3
  1329.  move.w  d2,(a3)
  1330.  lea     saveA7(pc),a3
  1331.  move.l  a7,(a3)
  1332.  movem.l (a7)+,d0-d7/a0-a6
  1333.  lea     savereg(pc),a7
  1334.  move.l  d0,(a7)
  1335.  move.l  saved0(pc),d0
  1336. Cd2Rn2:  dc.w 0
  1337.  move.l  savereg(pc),d0
  1338. here4:
  1339.  move.l  saveA7(pc),a7
  1340.  adda.l  #60,a7
  1341.  movem.l d0-d7/a0-a6,-(a7)
  1342.  move.l  62(a7),d4
  1343.  add.l   NumAdd(pc),d4
  1344.  move.l  d4,62(a7)
  1345.  move.l  ExecBase,a6
  1346.  jsr     Permit(a6)
  1347.  movem.l (a7)+,d0-d7/a0-a6
  1348.  rte
  1349.  
  1350.  
  1351. M_O_V_E_F_C_C_R:     ;Syntax: move CCR,<ea> = move CCR,d0 + move d0,<ea>
  1352.  move.l  62(a7),a0
  1353.  move.w  (a0),d1
  1354.  move.w  d1,d2
  1355.  andi.w  #$7,d1
  1356.  andi.w  #$38,d2
  1357.  lsl.w   #2,d1
  1358.  lsl.w   #7,d1
  1359.  lsl.w   #3,d2
  1360.  or.w    d2,d1
  1361.  lea     From(pc),a3
  1362.  move.l  #$4e714e71,4(a3)
  1363.  andi.w  #$f03f,(a3)
  1364.  or.w    d1,(a3)
  1365.  lsr.w   #6,d2
  1366.  cmpi.w  #$5,d2
  1367.  bne     tst2
  1368.  lea     NumAdd(pc),a4
  1369.  move.l  #4,(a4)       ;it is address reg. indirect with displ.
  1370.  move.w  2(a0),4(a3)
  1371.  bra     Here7
  1372. tst2:
  1373.  lsr.w   #6,d1
  1374.  cmpi.w  #$7,d1
  1375.  bne     tst3
  1376.  lea     NumAdd(pc),a4
  1377.  move.l  #4,(a4)
  1378.  move.w  2(a0),4(a3)
  1379.  bra     Here7
  1380. tst3:
  1381.  cmpi.w   #$f,d1
  1382.  bne      tst4
  1383.  lea      NumAdd(pc),a4
  1384.  move.l   #6,(a4)
  1385.  move.l   2(a0),4(a3)
  1386.  bra      Here7
  1387. tst4:
  1388.  lea      NumAdd(pc),a4
  1389.  move.l   #2,(a4)
  1390. Here7:
  1391.  lea      SaveVal(pc),a4
  1392.  move.w   60(a7),d0
  1393.  andi.w   #$00ff,d0
  1394.  move.w   d0,(a4)
  1395.  movem.l  (a7)+,d0-d7/a0-a6
  1396. From:
  1397.  move.w  SaveVal(pc),d0
  1398.  nop
  1399.  nop
  1400.  movem.l d0-d7/a0-a6,-(a7)
  1401.  move.l  62(a7),d4
  1402.  add.l   NumAdd(pc),d4
  1403.  move.l  d4,62(a7)
  1404.  move.l  ExecBase,a6
  1405.  jsr     Permit(a6)
  1406.  movem.l (a7)+,d0-d7/a0-a6
  1407.  rte
  1408.  
  1409.  
  1410. OldIllegalExcept:  dc.l 0
  1411. NewIllegalExcept:  dc.l 0
  1412. NewVec:            dc.l 0
  1413. Except:            dc.l 0
  1414. MyVBR:             dc.l 0
  1415. MySFC:             dc.l 0
  1416. MyDFC:             dc.l 0
  1417. MyCAAR:            dc.l 0
  1418. MyCACR:            dc.l 0
  1419. MySR:              dc.w 0
  1420. MySP:              dc.l 0
  1421. SaveVal:           dc.l 0
  1422. RetAddr:           dc.l 0
  1423. savea1:            dc.l 0
  1424. saved1:            dc.l 0
  1425. saved0             dc.l 0
  1426. savereg:           dc.l 0
  1427. saveA7:            dc.l 0
  1428. NumAdd:            dc.l 0
  1429.  
  1430. EndIllegal:
  1431.  end
  1432.  
  1433.